package com.capgemini.business.controller;

import com.capgemini.business.mapper.dataobject.ProjectManagement;
import com.capgemini.business.service.ProjectManagementService;
import com.capgemini.commons.response.Response;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/projects")
public class ProjectManagementController {

    @Resource
    private ProjectManagementService projectManagementService;


    @GetMapping("/list")
    public Response<List<ProjectManagement>> list() {
        return Response.success(projectManagementService.list());
    }


    @GetMapping("/get/{id}")
    public Response<ProjectManagement> getById(@PathVariable Integer id) {
        return Response.success(projectManagementService.findById(id));
    }


    @PostMapping("/add")
    public Response<String> save(@RequestBody ProjectManagement employee) {
        projectManagementService.save(employee);
        return Response.success("success");
    }

    @PostMapping("/update")
    public Response<String> update(@RequestBody ProjectManagement employee) {
        projectManagementService.update(employee);
        return Response.success("success");
    }

    @DeleteMapping("/delete/{id}")
    public Response<String> delete(@PathVariable Integer id) {
        projectManagementService.delete(id);
        return Response.success("success");
    }
}
